package com.nf;

import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.omg.CORBA.Request;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

public class App4 {
    public static void main(String[] args) throws SQLException {
        ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");

        ComboPooledDataSource pool = (ComboPooledDataSource)ac.getBean("xxxx");
        Connection con = pool.getConnection();

        PreparedStatement ps  = con.prepareStatement("select * from Girl");
        ResultSet rs = ps.executeQuery();
        while(rs.next()){
            String name = rs.getString("name");
            int age = rs.getInt("age");
            System.out.println(name+","+age);
        }
        ps.close();
        rs.close();
        con.close();
    }
}
